home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PRIVATE.ZIP / _INSWIN.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  91 lines

  1. #ifndef NO_MEMORY_H
  2. #include <memory.h>
  3. #endif
  4. #define        CURSES_LIBRARY  1
  5. #include <curses.h>
  6.  
  7. #ifdef REGISTERWINDOWS
  8. #ifndef        NDEBUG
  9. char *rcsid__inswin = "$Header: c:/curses/private/RCS/_inswin.c%v 2.0 1992/11/15 03:24:27 MH Rel $";
  10. #endif
  11.  
  12.  
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   _inswin()    - Register Window with PDCurses for auto refresh
  18.  
  19.   PDCurses Description:
  20.        This is a private PDCurses routine.
  21.  
  22.        This routine inserts the passed window pointer after the specified
  23.        window.  If the specified window is a (void*)0, then the passed
  24.        window pointer is inserted first in the list.
  25.  
  26.        If the 'before' window is not on the visible list, then 'win'
  27.        will be insed to the end of the list.
  28.  
  29.        This is the beginnings of full-tiled window support.  It is _very_
  30.        raw at this point.
  31.  
  32.   PDCurses Return Value:
  33.        This function returns OK on success and ERR on error.
  34.  
  35.   PDCurses Errors:
  36.        No errors are defined for this function.
  37.  
  38.   Portability:
  39.        PDCurses        bool    _inswin( WINDOW* win, WINDOW* before );
  40.  
  41. **man-end**********************************************************************/
  42.  
  43. bool   _inswin(WINDOW *win, WINDOW *before)
  44. {
  45. extern void*   (*mallc)( size_t );
  46. extern void*   (*callc)( size_t, size_t );
  47. extern void    (*fre)( void* );
  48.  
  49.        WINDS  *root = _cursvar.visible;
  50.        WINDS  *wlst = _findwin(before);
  51.        WINDS  *new  = (*mallc)(sizeof(WINDS));
  52.  
  53.        if (new == (WINDS *)NULL)
  54.                return( FALSE );
  55.  
  56.        _rmwin(win);
  57.        memset(new, 0, sizeof(WINDS));
  58.        new->w = win;
  59.        if (wlst == (WINDS *)NULL)
  60.        {
  61.                if (root == (WINDS *)NULL)
  62.                {
  63.                        _cursvar.visible = new;
  64.                }
  65.                else
  66.                {
  67.                        new->next = root;
  68.                        root->prev = new;
  69.                        _cursvar.visible = new;
  70.                }
  71.        }
  72.        else
  73.        {
  74.                if (wlst == root)
  75.                {
  76.                        new->next = root;
  77.                        root->prev = new;
  78.                        _cursvar.visible = new;
  79.                }
  80.                else
  81.                {
  82.                        new->next = wlst;
  83.                        new->prev = wlst->prev;
  84.                        wlst->prev->next = new;
  85.                        wlst->prev = new;
  86.                }
  87.        }
  88.        return( TRUE );
  89. }
  90. #endif
  91.